(function(){
  let headr = document.querySelector(".headr"),
nav_detail = document.querySelector('.nav-detail'),
    top_ul = document.querySelector('.top-ul'),
    major = document.querySelector('.major')

       // 获取到所有的祖先元素
    const gatAncestors = function gatAncestors(element){
        let arr = [element],
        parent = element.parentNode;
    while (parent){
        arr.push(parent);
        parent = parent.parentNode;
    }
    return arr;
    }

    // 监听时间源 事件委托
  document.addEventListener('mouseover',function(ev){
   let target = ev.target,
   ancsestors = gatAncestors(target);
   
      if(ancsestors.indexOf(top_ul)>-1){
        nav_detail.style.display = 'block';
        nav_detail.offsetWidth;
        nav_detail.style.transform= 'translateY(-8px)';
        return;
      }
      if(ancsestors.indexOf(nav_detail)>-1)return;
      nav_detail.style.display = 'none';
      nav_detail.style.transform= 'translateY(0px)';
  });

})()
